//3.动态申请一个整型数组，并给每个元素赋值，要求在第4个元素后插入100
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int *p = (int*)calloc(10,sizeof(int));	
	int n = 10;
	int m = 4;
	register int i = 0;
	for(i = 0; i < n; i++)
	{
		p[i] = rand() % 100;
		printf("%4d",p[i]);
	}
	printf("\n");
	int *q = realloc(p,sizeof(int) * (n+1));
	if(q == NULL)
	{
		puts("调整失败");
		free(p);
		return -1;
	}
	for(i = n; i >= 0; i--)
	{
		if(i+1 >= m)
		{
			q[i+1] = q[i];
		}
		if(i+1 == m)
		{
			q[i] = 100;
		}
	}
	for(i = 0; i < n+1; i++)
	{
		printf("%4d",q[i]);
	}
	printf("\n");
	free(q);
	
	return 0;
}
